<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix='sec' uri='http://www.springframework.org/security/tags'%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript" src="scripts/boot.js"></script>
</head>
<body style="border: 0px; margin: 0px; padding: 0px;width: 100%;height: 100%">
<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
    <table style="width:100%;">
        <tr>
        	<td style="width:100%;">
        	 	<sec:authorize url='/purchasing_power_fin_center.do'>
	        		<a class="mini-button" iconCls="icon-redo" onclick="onUser" plain="true">批量分配</a>
	        	</sec:authorize>
	        	<sec:authorize url='/buy_frequency_ms_export_all.do'>
	        		<a class="mini-button" iconCls="icon-download" plain="true" onclick="exportAll()">导出</a>
	        	</sec:authorize>
        	</td>
            <td style="white-space:nowrap;">
            	选择时间段：
        		<input id="start_time" class="mini-monthpicker" format="yyyy-MM" tooltip="请选择开始日期" showClose="true" oncloseclick="clearT" allowInput="false" style="width:100px;"/>
	        		&nbsp;—&nbsp;
	        		<input id="end_time" class="mini-monthpicker" format="yyyy-MM" tooltip="请选择截止日期" showClose="true" oncloseclick="clearT" allowInput="false" style="width:100px;"/>
				&nbsp;&nbsp;&nbsp;&nbsp;药品类别：
				<input id="medicine_sort" emptyText="请选择..." class="mini-treeselect" url="purchasing_power_medicine_sort.do" multiSelect="false"  valueFromSelect="true"
			        textField="name" showClose="true" oncloseclick="clearT" valueField="id" parentField="pid" allowInput="false" showRadioButton="true" showFolderCheckBox="false" popupWidth="200px;"/>
           		<a class="mini-button" iconCls="icon-search" onclick="search()">查询</a>
            </td>
        </tr>
    </table>           
</div>

<div class="mini-fit" >
<div id="datagrid1" class="mini-datagrid " idField="id" pageSize="20"
	url="buy_frequency_medical_view.do" multiSelect="true" style="width:100%;height:100%;">
	<div property="columns">
		<div type="checkcolumn"></div>
		<div type="indexcolumn" width="5%" headerAlign="center">排名</div>
		<div field="name" width="20%" headerAlign="center" align="center">姓名</div>
		<div field="countBuy" width="25%" headerAlign="center" align="center">购买次数</div>
		<div field="sexValue" width="25%" headerAlign="center" align="center">性别</div>
		<div field="phoneNum" width="25%" headerAlign="center" align="center">联系电话</div>
	</div>
</div>
</div>

<script type="text/javascript">
	mini.parse();
	var grid = mini.get("datagrid1");
	var startTime = mini.get("start_time");
	var endTime = mini.get("end_time");
	var myDate = new Date();
	var sm = myDate.getFullYear() + '-'+myDate.getMonth()+"";
	var em = myDate.getFullYear() + '-'+ (myDate.getMonth()+1+"");
	startTime.setValue(sm);
	endTime.setValue(em);
	grid.load({startTime: startTime.getFormValue(), endTime: endTime.getFormValue()});
	
	function search() {
		var medicineSort = mini.get("medicine_sort").getValue();
		grid.load({startTime: startTime.getFormValue(), endTime: endTime.getFormValue(), medicineSortId: medicineSort});
	}
	
	//导出所有
	function exportAll(){
		var startTime = mini.get("start_time").getFormValue();
		var endTime = mini.get("end_time").getFormValue();
		var medicineSort = mini.get("medicine_sort").getValue();
		
	    location.href="buy_frequency_ms_export_all.do?startTime="+startTime+"&endTime="+endTime+"&medicineSortId="+medicineSort;
	}
	
	function onUser(e){
		var callIds = getSelectRows();
		if(callIds.length > 0) {
			var el=e.sender.getEl();
			callUserCenter.load("purchasing_power_find_center.do");
			win1.showAtEl(el, {
			   xAlign:"center",
			   yAlign:"middle"
			});
		}else {
			mini.alert("未选择任何数据");
		}
	}
	
	function clearT(e){
			e.sender.setValue("");	
			e.sender.setText("");	
	}
</script>
</body>
</html>